package Test06;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

//IO流
//JDK9:IO流中捕获异常的写法
public class Test09 {
    public static void main(String[] args) throws FileNotFoundException {

        //JDK9:IO流中捕获异常的写法
        FileInputStream fis = new FileInputStream("D:\\工作\\src\\a.txt");
        FileOutputStream fos = new FileOutputStream("D:\\工作\\src\\copy.txt");
        try (fis;fos) {
            //2、拷贝
            //核心思想：边读边写
            int len;
            byte[] bytes = new byte[1024 * 1024 * 5];
            while ((len = fis.read(bytes)) != -1) {
                fos.write(bytes, 0, len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
